class Solution(object):
    def dailyTemperatures(self, temperatures):
        """
        :type temperatures: List[int]
        :rtype: List[int]
        """
        monotonic_stake = []
        next_temperature = [0] * len(temperatures)
        for i in range(0, len(temperatures)):
            while len(monotonic_stake) > 0 and monotonic_stake[-1][-1] < temperatures[i]:
                index, temperature = monotonic_stake.pop()
                next_temperature[index] = i - index
            monotonic_stake.append((i, temperatures[i]))
        return next_temperature
